<template>
	<div>
		<div class="ss">
			<el-steps :active="active" finish-status="success" simple style="margin-top: 20px">
				<el-step title="1. 确认回报内容"></el-step>
				<el-step title="2. 生成订单"></el-step>
				<el-step title="3. 完成"></el-step>
			</el-steps>
			<div style="height: 180px;width: 100%;">
				<blockquote style="border-left: 5px solid #f60; color:#f60;">
					<h3>
						请确认您所选择的回报项信息和购买数量
					</h3>
				</blockquote> <br>

				<el-table class="elel" :data="tableData">
					<el-table-column prop="iname" label="项目名称" width="210">
					</el-table-column>1068
					<el-table-column prop="fname" label="发起人" width="150">
					</el-table-column>
					<el-table-column prop="rinfo" label="回报内容" width="330">
					</el-table-column>
					
					<el-table-column label="支持数量" width="150">
						<template slot-scope="scope">
							<input style="width: 3.125rem; border:hidden;"  v-if="scope.row.payone==0" @blur="changeRP" v-model="tableData[0].snum" />
							<input style="width: 3.125rem; border:hidden;"  v-else  @blur="changeRP2(scope.row.payone)" v-model="tableData[0].snum" />
						</template>
						<!-- <input style="width: 3.125rem; border:hidden;" @blur="changeRP" v-model="tableData[0].snum" /> -->
					</el-table-column>
					<el-table-column prop="rnum" label="回报数量" width="150">
					</el-table-column>
					<el-table-column prop="onemoney" label="支持单价" width="150">
					</el-table-column>
					<el-table-column prop="yf" label="配送费用" width="150">
					</el-table-column>
				</el-table>

				<div style="float: right; height: 10%px;">
					<h4  style="margin-left: 50px;">总价钱：￥{{sum}}</h4>
					<blockquote style="border-left: 5px solid #f60;color:#f60;padding: 0 0 0 20px;">
						<el-button type="primary" @click="next" icon="el-icon-s-cooperation" style="float: right;">去结算
						</el-button>
					</blockquote>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				tableData: [{
					iname: '',
					fname: '',
					rinfo: '',
					snum: 1,
					rnum: '',
					onemoney: '',
					yf: '',
					payone:''
				}],
				rnum: 1,
				iid: '',
				mi: {},
				suppnum: 1,
				active: 0,
				sum: '',
				num: 1,
				ri: {
					itmans: '',
					rw: '',
					it: '',
					paynum: 1
				}
			}
		},
		methods: {
			changeRP() {
				this.tableData[0].rnum = this.tableData[0].snum * this.rnum;
				this.ri.rw.rewardnum = this.tableData[0].snum * this.rnum;
				this.ri.paynum = this.tableData[0].snum
				this.sum = this.tableData[0].snum * this.ri.rw.paymoney + this.ri.rw.yf;
			},
			changeRP2(payone) {
				this.tableData[0].rnum = this.tableData[0].snum * this.rnum;
				this.ri.rw.rewardnum = this.tableData[0].snum * this.rnum;
				this.ri.paynum = this.tableData[0].snum
				this.sum = this.tableData[0].snum * this.ri.rw.paymoney + this.ri.rw.yf;
				if(this.tableData[0].snum>payone){
					alert("你的输入超出限购"+payone+"，请重新输入")
				}
			},
			async selltt() {
				var rw = JSON.parse(this.$route.query.rr);
				// console.log(rw)
				var it = JSON.parse(this.$route.query.ii);
				// console.log(this.ri.it)
				this.iid = it.iid;
				var res = await this.$http.post("selectItemManByIid?iid=" + this.iid);
				if (res.data.code == 200) {
					this.ri.itmans = res.data.data

				}
				this.ri.it = it
				this.ri.rw = rw
				this.sum = this.ri.paynum * this.ri.rw.paymoney + this.ri.rw.yf;
				this.tableData[0].iname = this.ri.it.iname
				this.tableData[0].fname = this.ri.itmans.mshow
				this.tableData[0].rinfo = this.ri.rw.rewardcontext
				this.tableData[0].snum = this.ri.paynum
				this.tableData[0].payone = this.ri.rw.payone
				this.tableData[0].rnum = this.ri.rw.rewardnum
				this.rnum = this.ri.rw.rewardnum
				this.tableData[0].onemoney = this.ri.rw.paymoney
				this.tableData[0].yf = this.ri.rw.yf
				console.log(this.tableData)
			},
			next() {
				this.active = 1
				let aa = JSON.stringify(this.ri);
				this.$router.push({
					path: '/pay_step_2',
					query: {
						ra: aa,
					}
				})
			}


		},
		mounted() {
			this.selltt();

		}
	}
</script>

<style scoped="scoped">
	.ss {
		margin-top: 10px;
		margin-left: 100px;
		margin-right: 100px;
		border: #D3DCE6 solid;
	}
</style>
